﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EntityDataModel;
using System.Runtime.Serialization;

namespace LiveCPEWebService.Entity
{
    [DataContractAttribute]
    public class UserWS
    {
        [DataMember]
        public DateTime SubscriptionDate;
        [DataMember]
        public int NumFriends;
        [DataMember]
        public DateTime DateOfBirth;
        [DataMember]
        public String FirstName;
        [DataMember]
        public String LastName;
        [DataMember]
        public String UserName;
        [DataMember]
        public String Email;
        [DataMember]
        public String Password;
        [DataMember]
        public bool Gender;
        [DataMember]
        public byte[] Picture;
        // Peuplement de l'objet
        public void Generate(User pUser)
        {
            SubscriptionDate = pUser.SubscriptionDate;
            NumFriends = (int)pUser.NumFriends;
            try
            {
                DateOfBirth = (DateTime)pUser.DateOfBirth;
            }
            catch (Exception e)
            {
                DateOfBirth = DateTime.Now;
            }
            FirstName = pUser.FirstName;
            LastName = pUser.LastName;
            UserName = pUser.UserName;
            Gender = pUser.Gender;
        }
    }
}